home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Hiding a password
- Date: 05 Mar 1996 00:23:34 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar4172334@qcd.lanl.gov>
- References: <1996Feb29.224936.137160@forest> <4he620$qf2@hpbblb.bbn.hp.com>
- <4hehmd$1fr@fnord.dfw.net>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: ftlgeuse@dfw.dfw.net's message of 4 Mar 1996 10:46:37 GMT
-
- In article <4hehmd$1fr@fnord.dfw.net>
- ftlgeuse@dfw.dfw.net (Fetelgeuse) writes:
-
- <snip>
- F: I wrote a function to do precisely the same thing. I made a function
- F: something like:
- F: char * GetString_NoEcho()
- F: {
- F: char *temp;
- F: int i=1;
- F: while(temp[i-1]!=13) {
- F: temp[i-1]=getch();
- F: i++;
- F: }
- F: temp[i]=0;
- F: }
- F: I haven't really thought that out real well so you might find that the
- F: string index is the wrong value for any given character position but that
- F: would be easily fixed (if it is off, it would be off by 1 position) What
- F: it should do is place the return value of a series of getch()'s
- into temp[0],
- F: temp[1],temp[...], until the user enters [enter] and then where enter was
- F: gets replaced by a null. Anyway, like I said the indexes may be off but
- F: this way works when done properly.
-
- Please test your solutions before you post them. I tried the following
- program:
-
- #include <stdio.h>
- char * GetString_NoEcho()
- {
- char *temp;
- int i=1;
- while(temp[i-1]!=13) {
- temp[i-1]=getch();
- i++;
- }
- temp[i]=0;
- }
- int main(void) {
- char *pwd = GetString_NoEcho();
- printf("%s\n",pwd);
- return 0;
- }
-
- When I tried to compile it, I get
-
- j.c:3: warning: function declaration isn't a prototype
- j.c: In function `GetString_NoEcho':
- j.c:7: warning: implicit declaration of function `getch'
- j.c:4: warning: `temp' might be used uninitialized in this function
- j.c:11: warning: control reaches end of non-void function
- j.c: In function `main':
- j.c:13: warning: `pwd' might be used uninitialized in this function
- j.c:4: warning: `temp' might be used uninitialized in this function
- ld: Undefined symbol
- _getch
-
- and I get no executable.
-
- Can you help me? Any idea what I am doing wrong? Should I change the
- i-1 to i*=+5 to get it to work?
-
- If you haven't, please remember that when you post something that is
- wrong, you confuse a lot of other people. If you are merely trying to
- learn, please ask questions: do not pretend to know the answer when
- you don't.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-